{include file="./public/header" title="分配权限"/}
<link href="https://cdn.bootcss.com/bootstrap-validator/0.5.3/css/bootstrapValidator.min.css" rel="stylesheet">
<body class="hold-transition skin-blue fixed sidebar-mini">
<div class="wrapper">

    {include file="./public/navi"/}

    <!--页面主体-->
    <div class="content-wrapper">
        <section class="content-header">
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 后台</a></li>
                <li class="">用户组</li>
                <li class="active">编辑用户组</li>
            </ol>
        </section>
        <section class="content">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <div class="box-title">编辑</div>
                    <div class="box-tools">
                        <button onclick="javascript:history.back(-1);" type="button"
                                class="btn btn-box-tool"><i class="fa fa-chevron-left"></i> 返回
                        </button>
                        <button onclick="javascript:location.reload();" type="button"
                                class="btn btn-box-tool"><i class="fa fa-refresh"></i> 刷新
                        </button>
                    </div>
                </div>
                <div class="box-body">

                    <div class="nav-tabs-custom">
                        <ul class="nav nav-tabs">
                            <li class="active"><a href="{:url('/admin/auth/group/edit',array('id'=>$authGroups.id))}">编辑用户组</a></li>
                            <li class=""><a href="{:url('/admin/auth/group/assignrule',array('id'=>$authGroups.id))}">权限分配</a></li>
                        </ul>
                    </div>
                    <form class="form-horizontal" role="form" action="{:url('/admin/auth/group/update')}" method="post">
                        <input type="hidden" name="id" value="{$authGroups.id}">
                        <div class="form-group">
                            <label for="title" class="col-md-2 control-label">名称</label>
                            <div class="col-md-4">
                                <input type="text" class="form-control" id="title" name="title" value="{$authGroups.title}" required="">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="status" class="col-md-2 control-label">状态</label>
                            <div class="col-md-4">
                                <select class="form-control" id="status" name="status" value="" required>
                                    <option
                                            {if condition="$authGroups['status'] eq 1"}
                                            selected="selected"
                                            {/if}
                                    value="1">启用</option>
                                    <option
                                            {if condition="$authGroups['status'] eq 0"}
                                            selected="selected"
                                            {/if}
                                    value="0">禁用</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="remark" class="col-md-2 control-label">备注</label>
                            <div class="col-md-4">
                                <input type="text" class="form-control" id="remark" name="remark" value="{$authGroups.remark}" required="">
                            </div>
                        </div>
                        <hr>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-primary btn-flat">保存信息</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </section>
    </div>
    <!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

{include file="public/js"/}
<script src="https://cdn.bootcss.com/bootstrap-validator/0.5.3/js/bootstrapValidator.min.js"></script>
<script src="__STATIC__/lib/datatables/js/jquery.dataTables.min.js"></script>
<script src="__STATIC__/lib/datatables/js/dataTables.bootstrap.min.js"></script>
<script src="__STATIC__/lib/datatables-buttons/js/dataTables.buttons.min.js"></script>
<script src="__STATIC__/lib/datatables-buttons/js/jszip.min.js"></script>
<script src="__STATIC__/lib/datatables-buttons/js/buttons.html5.min.js"></script>
<script src="__STATIC__/lib/datatables-buttons/js/buttons.print.min.js"></script>

<script type="text/javascript">
    /* 多选判断 */
    function CheckAll(form) {
        for (var i = 0; i < form.elements.length; i++) {
            var e = form.elements[i];
            if (e.Name != 'chkAll' && e.disabled == false) {
                e.checked = form.chkAll.checked;
            }
        }
    }
</script>
<script type="text/javascript">
    /* 权限配置 */
    $(function () {
        //动态选择框，上下级选中状态变化
        $('input.checkbox-parent').on('change', function () {
            var dataid = $(this).attr("dataid");
            $('input[dataid^=' + dataid + ']').prop('checked', $(this).is(':checked'));
        });
        $('input.checkbox-child').on('change', function () {
            var dataid = $(this).attr("dataid");
            dataid = dataid.substring(0, dataid.lastIndexOf("-"));
            var parent = $('input[dataid=' + dataid + ']');
            if ($(this).is(':checked')) {
                parent.prop('checked', true);
                //循环到顶级
                while (dataid.lastIndexOf("-") != 2) {
                    dataid = dataid.substring(0, dataid.lastIndexOf("-"));
                    parent = $('input[dataid=' + dataid + ']');
                    parent.prop('checked', true);
                }
            } else {
                //父级
                if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
                    parent.prop('checked', false);
                    //循环到顶级
                    while (dataid.lastIndexOf("-") != 2) {
                        dataid = dataid.substring(0, dataid.lastIndexOf("-"));
                        parent = $('input[dataid=' + dataid + ']');
                        if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
                            parent.prop('checked', false);
                        }
                    }
                }
            }
        });
    });
</script>
</body>

</html>